import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class SparkThriftConn {
    public static void main(String[] args) throws Exception{
        Class.forName("org.apache.hive.jdbc.HiveDriver");
        Connection conn = DriverManager.getConnection("jdbc:hive2://slave6.htdata.com:10016", "hdfs", "");
//        PreparedStatement pstmt = conn.prepareStatement("select * from(select row_number() over(order by t) as r,* from view_loginlist where t>1534217849000)t where r between 5 and 16");
        PreparedStatement pstmt = conn.prepareStatement("select * from view_loginlist");
        long start = System.currentTimeMillis();
        ResultSet rs = pstmt.executeQuery();

        while (rs.next()) {
            System.out.println(rs.getInt(1)+"|"+rs.getString(2)+"|"+rs.getString(3)
            +"|"+rs.getString(4)+"|"
//                            +rs.getString(5)
            );
        }
        System.out.println("TIME:"+(System.currentTimeMillis()-start));
        rs.close();
        pstmt.close();
        conn.close();
    }
}
